package com.cf.controller;

import com.cf.domain.ResponseResult;
import com.cf.domain.pojo.Ground;
import com.cf.domain.pojo.TeamMember;
import com.cf.domain.pojo.TeamOrder;
import com.cf.domain.pojo.TeamScore;
import com.cf.domain.vo.TeamOrderVO;
import com.cf.domain.vo.TeamOrdersVO;
import com.cf.service.ITeamOrderService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpSession;
import java.util.List;

/**
 * @Author lzqinga@126.com
 * @Date 2024/11/12  19:39
 */
@Controller
@RequestMapping("/teamOrder")
@RequiredArgsConstructor
public class TeamOrderController {

    private final ITeamOrderService teamOrderService;

    @RequestMapping("/teamOrderUI")
    public String groundUI(@RequestParam(name = "groundId") Long groundId,
                           HttpSession session, Model model) {
        model.addAttribute("groundId", groundId);
        return "score/teamOrder";
    }

    @GetMapping("/list")
    @ResponseBody
    public ResponseResult list(){
        List<TeamOrder> data = teamOrderService.list();
        return ResponseResult.sucess(data);
    }

    @GetMapping("/order/{groundId}")
    @ResponseBody
    public ResponseResult getTeamOrderByGroundId(@PathVariable Long groundId){
        List<TeamOrderVO> data = teamOrderService.getTeamOrderByGroundId(groundId);
        return ResponseResult.sucess(data);
    }

    @PostMapping
    @ResponseBody
    public ResponseResult save(@RequestBody TeamOrdersVO teamOrdersVO){
        teamOrderService.saveList(teamOrdersVO);
        return ResponseResult.sucess();
    }

    /**
     * 大赛排行榜
     * @param type 赛道：1企业组；2高校组
     * @return
     */
    @GetMapping("/rank/{type}")
    @ResponseBody
    public ResponseResult list(@PathVariable("type") Integer type){
        return ResponseResult.sucess();
    }

}
